home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.1 KB | 205 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBndShp.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWBNDSHP_H
- #include "FWBndShp.h"
- #endif
-
- #ifndef SLGRGLOB_H
- #include "SLGrGlob.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRANSFORM_
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphxshape
- #endif
-
- FW_DEFINE_AUTO(FW_CBoundedShape)
- FW_DEFINE_CLASS_M1(FW_CBoundedShape, FW_CShape)
-
- //========================================================================================
- // class FW_CBoundedShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(const FW_CBoundedShape& other) :
- FW_CShape(other),
- fRect(other.fRect)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(const FW_CRect& rect,
- FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style,
- const FW_CFont& font) :
- FW_CShape(renderVerb, ink, style, font),
- fRect(rect)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::FW_CBoundedShape(FW_CReadableStream& stream) :
- FW_CShape(stream)
- {
- stream >> fRect;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::~FW_CBoundedShape
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape::~FW_CBoundedShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CBoundedShape& FW_CBoundedShape::operator=(const FW_CBoundedShape& other)
- {
- if (this != &other)
- {
- FW_CShape::operator=(other);
- fRect = other.fRect;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::HitTest
- //----------------------------------------------------------------------------------------
- // Only test if the point is inside the bounds
-
- FW_Boolean FW_CBoundedShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_Fixed tolerance) const
- {
- FW_UNUSED(gc);
- if(fRenderVerb == FW_kNoRendering)
- return FALSE;
-
- FW_CRect bounds(fRect);
- bounds.Inset(-tolerance, -tolerance);
- return bounds.Contains(test);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Transform
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Transform(Environment *ev, ODTransform* transform)
- {
- fRect.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Inset
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Inset(FW_Fixed h, FW_Fixed v)
- {
- fRect.Inset(h, v);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::GetBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const
- {
- FW_UNUSED(gc);
-
- rect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::GetAnchorPoint
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CBoundedShape::GetAnchorPoint() const
- {
- return fRect.TopLeft();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::InverseTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::InverseTransform(Environment *ev, ODTransform* transform)
- {
- fRect.InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::MoveShape
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::MoveShape(FW_Fixed deltaX, FW_Fixed deltaY)
- {
- fRect.left += deltaX;
- fRect.top += deltaY;
- fRect.right += deltaX;
- fRect.bottom += deltaY;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::MoveShapeTo
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::MoveShapeTo(FW_Fixed x, FW_Fixed y)
- {
- fRect.right += x - fRect.left;
- fRect.bottom += y - fRect.top;
- fRect.left = x;
- fRect.top = y;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBoundedShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CBoundedShape::Flatten(FW_CWritableStream& stream) const
- {
- FW_CShape::Flatten(stream);
- stream << fRect;
- }
-
-